/* ===================================
   设置模态框样式
   =================================== */

/* 设置模态框容器 */
.settings-modal {
  display: none;
  position: fixed;
  z-index: 10002;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.5);
  animation: fadeIn 0.3s;
}

.settings-modal-content {
  background-color: var(--card-bg-color);
  color: var(--text-color);
  margin: 3% auto;
  padding: 0;
  border-radius: 12px;
  box-shadow: 0 10px 40px var(--shadow-color);
  width: 90%;
  max-width: 900px;
  max-height: 90vh;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 模态框头部 */
.settings-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 25px;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: white;
}

.settings-modal-header h3 {
  margin: 0;
  font-size: 1.4em;
  font-weight: 600;
}

.settings-modal-close {
  color: rgba(255,255,255,0.8);
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.2s;
  line-height: 1;
}

.settings-modal-close:hover {
  color: white;
}

/* Tab 导航 */
.settings-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--input-bg-color);
  padding: 0 15px;
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  min-height: 48px;
}

.settings-tab {
  padding: 14px 20px;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-color);
  font-size: 0.95em;
  font-weight: 500;
  position: relative;
  transition: all 0.2s;
  white-space: nowrap;
  opacity: 0.7;
}

.settings-tab:hover {
  opacity: 1;
  background-color: rgba(0,0,0,0.03);
}

body.dark-mode .settings-tab:hover {
  background-color: rgba(255,255,255,0.05);
}

.settings-tab.active {
  opacity: 1;
  color: var(--color-primary);
}

.settings-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-primary);
  border-radius: 3px 3px 0 0;
}

/* Tab 内容区域 */
.settings-tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 25px;
}

.settings-tab-pane {
  display: none;
}

.settings-tab-pane.active {
  display: block;
  animation: fadeIn 0.3s;
}

/* 设置分组 */
.settings-group {
  margin-bottom: 25px;
  padding: 20px;
  background-color: var(--input-bg-color);
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.settings-group-title {
  font-size: 1.1em;
  font-weight: 600;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
  color: var(--color-primary);
}

/* 设置项样式 */
.settings-item {
  margin-bottom: 15px;
}

.settings-item:last-child {
  margin-bottom: 0;
}

.settings-item label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 0.95em;
}

.settings-item input[type="text"],
.settings-item input[type="number"],
.settings-item input[type="password"],
.settings-item select,
.settings-item textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: var(--card-bg-color);
  color: var(--text-color);
  font-size: 0.95em;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.settings-item input:focus,
.settings-item select:focus,
.settings-item textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.settings-item textarea {
  min-height: 100px;
  resize: vertical;
}

.settings-item .input-hint {
  font-size: 0.85em;
  color: var(--text-secondary);
  margin-top: 5px;
}

/* 行内布局 */
.settings-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

/* 测试按钮 */
.settings-test-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background-color: var(--color-info);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9em;
  transition: background-color 0.2s, transform 0.1s;
  margin-top: 10px;
}

.settings-test-btn:hover {
  background-color: var(--color-info-dark);
  transform: translateY(-1px);
}

.settings-test-btn:active {
  transform: translateY(0);
}

/* 提示词格式选择 */
.prompt-format-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.prompt-format-selector select {
  width: auto;
  min-width: 150px;
}

/* 条件显示区域 */
.settings-conditional {
  margin-top: 15px;
  padding: 15px;
  background-color: var(--card-bg-color);
  border-radius: 8px;
  border: 1px dashed var(--border-color);
}

/* 检测框扩展设置 */
.expand-settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.expand-settings-grid .settings-item {
  margin-bottom: 0;
}

.expand-settings-grid input {
  width: 70px !important;
}

/* Header 设置按钮 */
.settings-header-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background-color: rgba(100, 149, 237, 0.15);
  color: #4a6fa5;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.9em;
  transition: all 0.3s ease;
  text-decoration: none;
}

.settings-header-btn:hover {
  background-color: rgba(100, 149, 237, 0.25);
  transform: translateY(-2px);
}

.settings-header-btn .icon {
  font-size: 1.1em;
}

/* 模态框底部 */
.settings-modal-footer {
  padding: 15px 25px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background-color: var(--input-bg-color);
}

.settings-modal-footer button {
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95em;
  transition: all 0.2s;
}

.settings-save-btn {
  background: var(--color-success);
  color: white;
  border: none;
}

.settings-save-btn:hover {
  background: var(--color-success-dark);
}

.settings-cancel-btn {
  background: var(--card-bg-color);
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

.settings-cancel-btn:hover {
  background: var(--input-bg-color);
}

/* 响应式调整 */
@media (max-width: 768px) {
  .settings-modal-content {
    margin: 0;
    max-height: 100vh;
    border-radius: 0;
    width: 100%;
  }
  
  .settings-tabs {
    padding: 0 10px;
  }
  
  .settings-tab {
    padding: 12px 14px;
    font-size: 0.9em;
  }
  
  .settings-tab-content {
    padding: 15px;
  }
  
  .settings-row {
    grid-template-columns: 1fr;
  }
}

/* 淡入动画 */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 已保存提示词下拉 */
.saved-prompts-section {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px dashed var(--border-color);
}

.saved-prompts-section h5 {
  margin: 0 0 10px 0;
  font-size: 0.9em;
  color: var(--text-secondary);
}

.saved-prompt-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--card-bg-color);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.saved-prompt-item:hover {
  border-color: var(--color-primary);
  background: rgba(52, 152, 219, 0.05);
}

.saved-prompt-item .prompt-name {
  font-weight: 500;
}

.saved-prompt-item .prompt-delete {
  color: var(--color-danger);
  cursor: pointer;
  padding: 2px 6px;
}

/* 复选框样式优化 */
.settings-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.settings-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.settings-checkbox label {
  margin: 0;
  cursor: pointer;
}

/* 分隔线 */
.settings-divider {
  height: 1px;
  background: var(--border-color);
  margin: 20px 0;
}

/* API Key 显示/隐藏按钮 */
.api-key-wrapper {
  position: relative;
}

.api-key-wrapper input {
  padding-right: 40px;
}

.api-key-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 1.1em;
}

.api-key-toggle:hover {
  color: var(--text-color);
}

/* ===================================
   侧边栏精简样式
   这些设置元素现在通过HTML的display:none隐藏，仅保留用于数据同步
   =================================== */

.sidebar-hidden-config {
  display: none !important;
}

/* 隐藏校对设置按钮（功能已移到设置模态框） */
#proofreadSettingsButton {
  display: none !important;
}

/* 隐藏原来的AI校对设置弹窗（功能已整合到设置模态框） */
#proofreadingSettingsModal {
  display: none !important;
}

/* AI校对轮次在设置模态框中的样式 */
.settings-proofreading-round {
  margin-bottom: 20px;
}

.settings-proofreading-round .settings-group {
  background: var(--card-bg-color);
}

.settings-proofreading-round .round-name-input {
  color: var(--color-primary);
  padding: 4px 8px;
  border-radius: 4px;
}

.settings-proofreading-round .round-name-input:hover,
.settings-proofreading-round .round-name-input:focus {
  background: var(--input-bg-color);
  outline: none;
}

/* ===================================
   本地模型列表样式
   用于Ollama/Sakura模型选择
   =================================== */

.model-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  background: var(--card-bg-color);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  min-height: 50px;
}

.model-list .model-button {
  padding: 6px 12px;
  background: var(--input-bg-color);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
  color: var(--text-color);
  transition: all 0.2s;
}

.model-list .model-button:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.model-list .model-button.selected {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
  font-weight: 500;
}

/* Toast消息样式 */
.settings-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 8px;
  color: white;
  font-size: 0.95em;
  z-index: 99999; /* 最高层级，确保在编辑模式等所有元素之上 */
  animation: toastFadeIn 0.3s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.settings-toast.success {
  background: rgba(82, 196, 26, 0.85);
}

.settings-toast.error {
  background: rgba(255, 77, 79, 0.85);
}

.settings-toast.warning {
  background: rgba(250, 173, 20, 0.85);
}

.settings-toast.info {
  background: rgba(24, 144, 255, 0.85);
}

@keyframes toastFadeIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ===================================
   提示词选择器样式
   用于快速选择已保存的提示词
   =================================== */

.saved-prompts-picker {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--input-bg-color);
  border: 1px solid var(--border-color);
  border-radius: 6px;
}

.saved-prompts-picker .picker-label {
  font-size: 0.85em;
  color: var(--text-secondary-color);
  margin-right: 10px;
  white-space: nowrap;
}

.prompts-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  min-height: 32px;
  align-items: center;
}

.prompts-chips-container .prompt-chip {
  padding: 5px 12px;
  background: var(--card-bg-color);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  cursor: pointer;
  font-size: 0.85em;
  color: var(--text-color);
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.prompts-chips-container .prompt-chip:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.prompts-chips-container .prompt-chip .chip-icon {
  font-size: 0.9em;
}

.prompts-chips-container .empty-hint {
  font-size: 0.85em;
  color: var(--text-secondary-color);
  font-style: italic;
}

/* ===================================
   提示词管理页面样式
   =================================== */

.prompt-library-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
  padding: 5px;
}

.prompt-library-list .empty-prompt-hint {
  text-align: center;
  color: var(--text-secondary-color);
  padding: 30px;
  font-style: italic;
}

.prompt-library-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 15px;
  background: var(--input-bg-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: all 0.2s;
}

.prompt-library-item:hover {
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.prompt-library-item .prompt-info {
  flex: 1;
  min-width: 0;
}

.prompt-library-item .prompt-name {
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.prompt-library-item .prompt-name .prompt-icon {
  color: var(--color-primary);
}

.prompt-library-item .prompt-preview {
  font-size: 0.85em;
  color: var(--text-secondary-color);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 500px;
}

.prompt-library-item .prompt-actions {
  display: flex;
  gap: 8px;
  margin-left: 15px;
  flex-shrink: 0;
}

.prompt-library-item .prompt-action-btn {
  padding: 5px 10px;
  border: 1px solid var(--border-color);
  background: var(--card-bg-color);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85em;
  color: var(--text-color);
  transition: all 0.2s;
}

.prompt-library-item .prompt-action-btn:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.prompt-library-item .prompt-action-btn.delete-btn:hover {
  background: #ff4d4f;
  border-color: #ff4d4f;
}

/* 提示词编辑区域 */
.prompt-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--border-color);
}

/* AI校对轮次内的提示词选择器样式调整 */
.settings-proofreading-round .saved-prompts-picker {
  margin-top: 8px;
  padding: 8px 10px;
}

.settings-proofreading-round .prompts-chips-container {
  margin-top: 6px;
  min-height: 28px;
}

.settings-proofreading-round .prompt-chip {
  padding: 4px 10px;
  font-size: 0.8em;
}

/* ===================================
   密码输入框眼睛切换按钮
   =================================== */
.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.password-input-wrapper input[type="password"],
.password-input-wrapper input[type="text"] {
  flex: 1;
  padding-right: 36px;
}

.password-toggle-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-color-secondary, #666);
  opacity: 0.6;
  transition: opacity 0.2s;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.password-toggle-btn:hover {
  opacity: 1;
}

.password-toggle-btn .eye-icon {
  display: inline;
}

.password-toggle-btn .eye-off-icon {
  display: none;
}

.password-toggle-btn.showing .eye-icon {
  display: none;
}

.password-toggle-btn.showing .eye-off-icon {
  display: inline;
}

/* ===================================
   模型获取按钮和选择器样式
   =================================== */
.model-input-with-fetch {
  display: flex;
  gap: 8px;
  align-items: center;
}

.model-input-with-fetch input {
  flex: 1;
}

.fetch-models-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--color-primary, #4a90d9);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85em;
  white-space: nowrap;
  transition: all 0.2s;
}

.fetch-models-btn:hover {
  background: var(--color-primary-dark, #3a7bc8);
  transform: translateY(-1px);
}

.fetch-models-btn:active {
  transform: translateY(0);
}

.fetch-models-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

.fetch-models-btn.loading {
  pointer-events: none;
}

.fetch-models-btn.loading .fetch-icon {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.fetch-icon {
  font-size: 1em;
}

.model-select-container {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.model-select {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border-color, #ddd);
  border-radius: 6px;
  background: var(--input-bg, #fff);
  color: var(--text-color, #333);
  font-size: 0.9em;
  cursor: pointer;
}

.model-select:focus {
  outline: none;
  border-color: var(--color-primary, #4a90d9);
  box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.2);
}

.model-count {
  font-size: 0.8em;
  color: var(--text-color-secondary, #666);
  white-space: nowrap;
}

/* ===================================
   安全文本输入框 (避免浏览器密码警告)
   =================================== */
input.secure-input {
  -webkit-text-security: disc;
}

input.secure-input.showing {
  -webkit-text-security: none;
}
